package com.xbts.system.domain;

import java.math.BigDecimal;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import com.xbts.common.annotation.Excel;
import com.xbts.common.utils.StringUtils;
import com.xbts.common.core.domain.BaseEntity;

/**
 * 用户购买记录（虚拟）对象 cn_virtually_user_buy_log
 *
 * @author xbts
 * @date 2023-11-30
 */
@Data
@ApiModel("用户购买记录（虚拟）对象")
@TableName("cn_virtually_user_buy_log")
public class CnVirtuallyUserBuyLog extends BaseEntity {

    private static final long serialVersionUID=1L;

    /** ID */
    private String Id;

    /** 用户ID */
    @NotEmpty(message = "用户ID不能为空")
    private String userId;

    @Excel(name = "用户名")
    @TableField(exist = false)
    private String nickName;

    /** 服务类型名称 */
    @Excel(name = "服务类型")
    @ApiModelProperty("服务类型")
    private String serviceTypeName;

    /** 产品类型名称 */
    @Excel(name = "产品类型")
    @ApiModelProperty("产品类型")
    private String productTypeName;

    /** 产品名称 */
    @Excel(name = "产品名称")
    @ApiModelProperty("产品名称")
    private String productName;

    /** 配置 */
    @Excel(name = "配置")
    @ApiModelProperty("配置")
    private String productConfig;

    /** 数量 */
    @Excel(name = "数量")
    @ApiModelProperty("数量")
    private String productCount;

    /** 金额 */
    @Excel(name = "金额")
    @ApiModelProperty("金额")
    private BigDecimal amount;

    /** 备注 */
    @Excel(name = "备注")
    private String remark;

    /** 开始时间 */
    @TableField(exist = false)
    private String beginTime;

    /** 结束时间 */
    @TableField(exist = false)
    private String endTime;

    /** 结束时间 */
    @TableField(exist = false)
    private List<CnVirtuallyUserBuyLog> list;



    public<T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> queryWrapper=new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(userId),"ubl.user_id",userId);
        queryWrapper.like(StringUtils.isNotEmpty(nickName),"uha.nick_name",nickName);
        queryWrapper.like(StringUtils.isNotEmpty(productTypeName),"ubl.product_type_name",productTypeName);
        queryWrapper.like(StringUtils.isNotEmpty(productName),"ubl.product_name",productName);
        queryWrapper.like(StringUtils.isNotEmpty(serviceTypeName),"ubl.service_type_name",serviceTypeName);
        if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
            queryWrapper.ge("ubl.create_time", beginTime);
            queryWrapper.le("ubl.create_time", endTime);
        }
        queryWrapper.orderByDesc("ubl.create_time");
        return queryWrapper;
    }
}